package com.laiketui.common.utils.tool;

/**
 * 字符串帮助类
 * @author wangxian
 */
public class StringUtils {

    /**
     *
     * @param str
     * @param splitter
     * @return
     */
    public static String trim(String str, String splitter) {
        String regex = "^" + splitter + "*|" + splitter + "*$";
        return str.replaceAll(regex, "");
    }

    /**
     *
     *
     * @param str
     * @param splitter
     * @return
     */
    public static String ltrim(String str, String splitter) {
        String regex = "^" + splitter + "*";
        return str.replaceAll(regex, "");
    }

    /**
     * 删掉左边的空格
     *
     * @param str
     * @param splitter
     * @return
     */
    public static String rtrim(String str, String splitter) {
        String regex = splitter + "*$";
        return str.replaceAll(regex, "");
    }

    /**
     *
     * @param args
     */
    public static void main(String[] args) {
        String context = "abbaa- sfad dfd fdf  bb-bbb";
        System.out.println(rtrim(context,"b"));
        System.out.println(ltrim(context,"a"));
        System.out.println(trim(context,"a"));
    }


}
